﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Perfiles.aspx.cs" Inherits="Proyectos_Perfiles_Perfiles" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Register Src="wucPerfiles.ascx" TagName="wucPerfiles" TagPrefix="ucP" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link rel="stylesheet" type="text/css" href="../../resources/css/rownumber.css" />
</head>
<body>
    <form id="form1" runat="server">
    <ext:ResourceManager ID="smPerfiles" runat="server"/>
    <script type="text/javascript" language="javascript" src="../../resources/utilidades.js"></script>
    <ext:Store ID="StoreProgramas" runat="server">
        <Reader>
            <ext:JsonReader IDProperty="Key">
                <Fields>
                    <ext:RecordField Name="Value">
                    </ext:RecordField>
                    <ext:RecordField Name="Key">
                    </ext:RecordField>
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Store ID="StoreEje" runat="server">
        <Reader>
            <ext:JsonReader IDProperty="Key">
                <Fields>
                    <ext:RecordField Name="Value">
                    </ext:RecordField>
                    <ext:RecordField Name="Key">
                    </ext:RecordField>
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Store ID="StoreProyectos" runat="server" OnRefreshData="BuscarProyectos" AutoLoad="false">
        <Reader>
            <ext:JsonReader IDProperty="Id">
                <Fields>
                    <ext:RecordField Name="Id" />
                    <ext:RecordField Name="Nombre" />
                    <ext:RecordField Name="Descripcion" />
                    <ext:RecordField Name="Tipo" />
                    <ext:RecordField Name="Estado" />
                    <ext:RecordField Name="Latitud" />
                    <ext:RecordField Name="Longitud" />
                    <ext:RecordField Name="Dictamen" />
                    <ext:RecordField Name="Viabilidad" />
                </Fields>
            </ext:JsonReader>
        </Reader>
        <Proxy>
        <ext:PageProxy></ext:PageProxy>
        </Proxy>
        <BaseParams>
        <ext:Parameter Name="Categoria" Mode="Raw" Value="#{cbxEje}.getValue()"></ext:Parameter>
        <ext:Parameter Name="Sub" Mode="Raw" Value="#{cbxProgramas}.getValue()"></ext:Parameter>
        </BaseParams>
    </ext:Store>
    <ext:Store ID="StoreEstado" runat="server">
        <Reader>
            <ext:JsonReader IDProperty="Key">
                <Fields>
                    <ext:RecordField Name="Value">
                    </ext:RecordField>
                    <ext:RecordField Name="Key">
                    </ext:RecordField>
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Store ID="sTipo" runat="server">
        <Reader>
            <ext:JsonReader IDProperty="Key">
                <Fields>
                    <ext:RecordField Name="Value">
                    </ext:RecordField>
                    <ext:RecordField Name="Key">
                    </ext:RecordField>
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    

    <ext:Panel ID="Panel1" BodyStyle="padding:15px;background-color:#E7E4DD;" runat="server"
        AutoHeight="true">
        <Items>
            <ext:Panel Border="false" BodyStyle="padding:10px;background-color:Transparent;" ButtonAlign="Center"
                runat="server"   Layout="Column" Height="90">
                <Items>
                        <ext:Panel runat="server" Border="false" Header="false" BodyStyle="padding:10px;background-color:Transparent;"
                            ColumnWidth=".5" Layout="Form">
                            <Items>
                                <ext:ComboBox Editable="false" FieldLabel="Eje" ID="cbxEje" StoreID="StoreEje" runat="server"
                                    DisplayField="Value" ValueField="Key" TypeAhead="true" ForceSelection="true"
                                    AnchorHorizontal="95%" TriggerAction="All" Grow="true" GrowMax="300" EmptyText="Todos"
                                    SelectOnFocus="true" AutoDataBind="True">
                                    <Triggers>
                                        <ext:FieldTrigger Icon="Clear" HideTrigger="true" />
                                    </Triggers>
                                    <Listeners>
                                        <Select Handler="this.triggers[0].show();" />
                                        <BeforeQuery Handler="this.triggers[0][ this.getRawValue().toString().length == 0 ? 'hide' : 'show']();" />
                                        <TriggerClick Handler="if(index == 0) { this.clearValue(); this.triggers[0].hide(); }" />
                                    </Listeners>
                                </ext:ComboBox>
                            </Items>
                        </ext:Panel>
                        <ext:Panel runat="server" Border="false" BodyStyle="padding:10px;background-color:Transparent;"
                            ColumnWidth=".5" Layout="Form">
                            <Items>
                                <ext:ComboBox Editable="false" FieldLabel="Programa" ID="cbxProgramas" runat="server"
                                    StoreID="StoreProgramas" DisplayField="Value" ValueField="Key" TypeAhead="true"
                                    ForceSelection="true" TriggerAction="All" Grow="true" GrowMax="300" EmptyText="Todos"
                                    SelectOnFocus="true" AutoDataBind="True" AnchorHorizontal="95%">
                                    <Triggers>
                                        <ext:FieldTrigger Icon="Clear" HideTrigger="true" />
                                    </Triggers>
                                    <Listeners>
                                        <Select Handler="this.triggers[0].show();" />
                                        <BeforeQuery Handler="this.triggers[0][ this.getRawValue().toString().length == 0 ? 'hide' : 'show']();" />
                                        <TriggerClick Handler="if(index == 0) { this.clearValue(); this.triggers[0].hide(); }" />
                                    </Listeners>
                                </ext:ComboBox>
                            </Items>
                        </ext:Panel>
                </Items>
                 <Buttons>
                    <ext:Button runat="server" ID="Button1" Text="Buscar" Icon="Find">
                    <Listeners>
                    <Click Handler="#{StoreProyectos}.load();" />
                    </Listeners>
                        <%--<DirectEvents>
                            <Click OnEvent="btnBuscar_Click">
                                <EventMask ShowMask="true" />
                            </Click>
                        </DirectEvents>--%>
                    </ext:Button>
               </Buttons>
            </ext:Panel>
        </Items>
    </ext:Panel>
    <ext:GridPanel runat="server" Border="false" ID="gpPerfilProyecto" StoreID="StoreProyectos"
        Height="380" AutoExpandColumn="DescripcionProyecto" EnableColumnHide="false"
        StripeRows="true" TrackMouseOver="true">
        <TopBar>
            <ext:Toolbar ID="tobPerfilProyecto" runat="server">
                <Items>
                    <ext:Button runat="server" ID="btnNuevo" Text="Nuevo Perfil de Proyecto" Icon="Add">
                        <DirectEvents>
                            <Click OnEvent="btnNuevo_click">
                                <ExtraParams>
                                    <ext:Parameter Name="operacion" Value="Nuevo">
                                    </ext:Parameter>
                                </ExtraParams>
                            </Click>
                        </DirectEvents>
                    </ext:Button>
                </Items>
            </ext:Toolbar>
        </TopBar>
        <ColumnModel ID="clmBuscarPerfilProyecto" runat="server">
            <Columns>
                <ext:RowNumbererColumn Width="20">
                </ext:RowNumbererColumn>
                <ext:CommandColumn Width="50">
                    <Commands>
                        <ext:GridCommand ToolTip-Text="Editar Perfil de Proyecto" Icon="PageEdit" CommandName="Editar">
                        </ext:GridCommand>
                        <ext:GridCommand ToolTip-Text="Eliminar Perfil de Proyecto" Icon="PageDelete" CommandName="Eliminar">
                        </ext:GridCommand>
                    </Commands>
                </ext:CommandColumn>
                <ext:Column ColumnID="NombreProyecto" Header="Proyecto" Width="200" DataIndex="Nombre" />
                <ext:Column DataIndex="Tipo" Header="Tipo" Width="100">
                    <Renderer Fn="columnaRendererTipo" />
                </ext:Column>
                <ext:Column ColumnID="DescripcionProyecto" DataIndex="Descripcion" Header="Descripción"
                    Width="200" />
                <ext:Column DataIndex="Estado" Header="Estado" Width="100">
                    <Renderer Fn="columnaRenderer" />
                </ext:Column>
                <ext:Column DataIndex="Dictamen" Header="Dictamen" Width="100" />
                <ext:Column DataIndex="Viabilidad" Header="Viabilidad" Width="100" />
            </Columns>
        </ColumnModel>
        <LoadMask ShowMask="true" />
        <SaveMask ShowMask="true" />
        <DirectEvents>
            <Command OnEvent="Editar_Click">
                <EventMask ShowMask="true" Target="CustomTarget" CustomTarget="={#{gpPerfilProyecto}.body}" />
                <ExtraParams>
                    <ext:Parameter Name="id" Value="record.data.Id" Mode="Raw" />
                    <ext:Parameter Name="operacion" Value="command" Mode="Raw" />
                </ExtraParams>
            </Command>
        </DirectEvents>
        <SelectionModel>
            <ext:RowSelectionModel ID="rsmPerfilProyecto" runat="server" />
        </SelectionModel>
        <BottomBar>
            <ext:PagingToolbar ID="ptbPerfilProyecto" runat="server" StoreID="StoreProyectos"
                DisplayInfo="true" DisplayMsg="Perfiles de Proyectos {0} - {1} of {2}" EmptyMsg="No existen Perfiles de Proyectos" />
        </BottomBar>
    </ext:GridPanel>
    <ucP:wucPerfiles runat="server" ID="wucPerfiles1" />
    <ext:XScript ID="XScript1" runat="server">
<script type="text/javascript" language="javascript">
        
        var columnaRenderer = function(value) {
                var r = #{StoreEstado}.getById(value);

                if (Ext.isEmpty(r)) {
                    return value;
                }

                return r.data['Value'];
            };
            var columnaRendererTipo = function(value) {
                var r = #{sTipo}.getById(value);

                if (Ext.isEmpty(r)) {
                    return value;
                }

                return r.data['Value'];
            };
    </script>
    </ext:XScript>
    </form>
</body>
</html>
